package com.ruoyi.activiti.controller;

import com.ruoyi.activiti.domain.TestUser;
import com.ruoyi.activiti.service.TestSysUserService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.AjaxPageResult;
import com.ruoyi.common.core.web.page.TableSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TestSysUserController extends BaseController {

    @Autowired
    private TestSysUserService testSysUserService;

    /**
     * 查询测试用例列表
     */
    @GetMapping("/users" )
    public AjaxPageResult list() {
        TableSupport.startPage();
        List<TestUser> list = testSysUserService.list();
        return AjaxPageResult.success(list);
    }

    @GetMapping("/mapperList" )
    public AjaxPageResult mapperList() {
        TableSupport.startPage();
        List<TestUser> list = testSysUserService.mapperList();
        return AjaxPageResult.success(list);
    }

    @GetMapping("/xmlList" )
    public AjaxPageResult xmlList() {
        TableSupport.startPage();
        List<TestUser> list = testSysUserService.xmlList();
        return AjaxPageResult.success(list);
    }

    @PostMapping("addTestUser")
    public AjaxResult addTestUser(@RequestBody TestUser testUser){
        testSysUserService.save(testUser);
        return AjaxPageResult.success(testUser);
    }

    @DeleteMapping("/user/{userId}")
    public AjaxResult removeUser(@PathVariable("userId") String userId){
        boolean bool = testSysUserService.removeById(userId);
        return AjaxPageResult.success(bool);
    }
}
